home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 10 Scripting / 01 Berger / README.txt < prev    next >
Encoding:
Text File  |  2001-10-09  |  1.7 KB  |  40 lines

  1. This directory contains the sample source code for a very simple compiler
  2. called SCC.  This compiler is not very practical, but it illustrates the
  3. basics of how a compiler can translate a script source code into bytecode
  4. stream.
  5.  
  6. In order to compile this sample program, you will need working copies of
  7. GNU Bison and GNU Flex (Flex is a lexical analyzer commonly used in
  8. conjunction with Bison).  Since Microsoft Visual C++ 6.0 was the target
  9. platform for this source code, I suggest installing the Cygwin utilities.
  10. Cygwin is a UNIX environment for Windows, and it contains working copies
  11. of Bison & Flex.
  12.  
  13.                           http://www.cygwin.com/
  14.  
  15. Once you have Cygwin installed and in your path, you should be able to
  16. build this example by simply running nmake.  The sample program will be
  17. generated in Debug\scc.exe.
  18.  
  19. Executing this program is pretty straight forward.  Create a text file
  20. that contains the source code you want to compile, and pass this file as
  21. an argument to scc.  For example:
  22.  
  23.                             scc TestScript.scc
  24.  
  25. The program will write to the screen the parse tree node, and the
  26. generated bytecode stream will be written to out.bin.
  27.  
  28. The language that the compiler understands is very simple.  The more
  29. complicated language constructs where omitted in order to help illustrate
  30. the basic code generation techniques.  Source scripts can consist of any
  31. number of lines of basic math instructions.  Only integers are supported,
  32. and each line must be terminated with a semi-color.  The following are
  33. examples of valid input for the script:
  34.  
  35.    10-9*3;
  36.    4+5;
  37.    10/3-5*(2/10);
  38.  
  39. A small sample script is included in the file sample.scc.
  40.